package cn.smbms.util;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * @Classname SMBSHandlerExceptionResolver
 * @Description TODO
 * @Date 2020-10-12 10:17
 * @Created by 26440
 */
@ControllerAdvice
public class SMBSHandlerExceptionResolver {
    @ExceptionHandler(RuntimeException.class)
    public String exceptionHandler(RuntimeException e, HttpServletRequest request) {
        e.printStackTrace();
        //请异常存储到请求中
        System.out.println("额外的异常处理");
        request.setAttribute("exception", e);
        return "forward:error.jsp";
    }
}
